/**
 * Copyright 2002 Cordys R&D B.V. 
 * 
 * This file is part of the Cordys .NET Connector. 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 #if !defined(AFX_NATIVETOCTS_H__INCLUDED_)
#define AFX_NATIVETOCTS_H__INCLUDED_

//@Author	: Lejil 
//@Class	: NativeToCTS
//
//		 Parse Request and then create .NET Types
//		 Create Equivalent .NET Data Types

#pragma once
#include "stdafx.h"
#include "Parameters.h"
using namespace System::Xml;

__gc class NativeToCTS : public Parameters
		{
		
		public :
			/**	
			*	CONSTRUCTOR
			*		Create the Instance
			*		call the methiods to parse the  request Node & implementation Node,
			*			Initialise the values
			*  
			*  <implementation type="DotnetCall">
			*	<assembly>D:\jnetTestCases\bin\Debug\jnetTestCases.dll</assembly>
			*	<class>jnetTestCases.arithmetic.Calculate</class>
			*	<method dt="int" scope="out" ct="" static="true">Add</method>
			*    <parameters>
			*		<param1 dt="int"/>
			*		<param2 dt="int"/>
			*   </parameters>
			* </implementation>
			*/			
			NativeToCTS(int request,int implementation)
			{
				try
				{
					requestNode			=	request;
					//mtdParamTypeNode	=	Find::FirstMatch(implementation,"?<parameters>");
					mtdParamTypeNode	=	Node::GetElement(implementation,"parameters");
				 	ParseImplementation(implementation);
					ParseRequest(request,mtdParamTypeNode);
				}
				catch(Exception *ex)
				{
					throw ex;
				}
			}
			
			//	This return the Parameters Object,
			//        Arguments required for calling the  .NET method
			//
			__property Parameters __gc* get_Parameter()
			{
				return static_cast<Parameters __gc*>(this);
			}

			/**
			 *     Destructor
			 *       This will get called , when calling delete on the
			 *			created instance of this class.
			 */
			~NativeToCTS()
			{
			}
			
		private:
			/**
			 *  Parse Request Node and Initialise the values, that are
			 *		required for calling the .NET Method
			 */
			void  ParseRequest(int request,int typeNode);
			/**
			 *  Parse Implementation of the Cordys Web Method and Initialise the
             *		values, that arerequired for calling the .NET Method
			 */
			void  ParseImplementation(int implementation);
			
			/**
			 *  Prepare the Argument array for calling the
			 *		.NET methods or Constructor
			 *		arguments are
			 *	1 - >	argumentNode,(method argument values).Get this from Request 
			 *	2 - >	dataTypeNode,(method arguemnt dataType). Get this from implemntation
			 */
			Object __gc * ConvertArguments(int argumentNode ,int dataTypeNode)[];
			/**
			 *   Create an XmlDocument from Sting in xml format, if 
			 *	he method or Constructor arguments are xml
			 */
			XmlDocument __gc *CovertToXmlDocument(int xmlArgumentNode);
			
		};

#endif 